{include file="public/header"}
{load href="/public/static/Content/ThemesBusiness/ListPage.css"}
{load href="/public/static/Content/ThemesBusiness/FormPage.css"}
<script src="/public/static/Scripts/common-binder-list-view.js"></script>
<script src="/public/static/Scripts/ScriptsEasyui/datagrid-filter.js"></script>
<style>
    .datagrid-view {
        overflow-x: scroll;
    }
</style>

<script type="text/javascript">

    var data = null;
   
    $(function () {
      
         $('#gridList').datagrid({
            url:'/admin/proview/good_list.html?ajax=1&gid={$gid}&tag_id={$tag_id}',
            remoteSort: false,
            sortOrder: 'desc',
            //sortName: 'name',

         });
    });

   



    function EditRecord(id) {
        //alert(id);return;
        if (id <= 0) {
            $.messager.alert('提示', "没有ID", 'info');
            return 0;
        } else {
            window.showBusinessForm("商品编辑", '/admin/proview/edit.html?id=' + id);
        }


    }

    function Editmoresn(id) {
        //alert(id);return;
        if (id <= 0) {
            $.messager.alert('提示', "没有ID", 'info');
            return 0;
        } else {
            window.showBusinessForm("关联序列号", '/admin/proview/moresn.html?id=' + id);
        }
    }



    function formatAction(val, row, index) {

        val = {eq name="power.edit" value="true"}'<a href="#" style="float:left" title="编辑" onclick="EditRecord(' + row.id + ')"><div class="icon-page-edit"></div></a>' +{/eq}
        '<a href="#" style="float:left" title="关联序列号" onclick="Editmoresn(' + row.id + ')"><div class="icon-page-splb"></div></a>'
        ;
        return val;
    }

    function Search() {

        var str = "";
        // if($("#GroupID").combo('getValue')!=0){
        //     str+="GroupID="+$("#GroupID").combo('getValue')+"&";
        // }

        if ($("#Search").val() != "") {
            str += $("#Search").val();
        }
        var stime = $('#stime').datebox('getValue');
        var etime = $('#etime').datebox('getValue');
        //console.log(stime);
        //return false;


        if (stime != "" && etime == "") {
            $.messager.alert('提示', '请先输入结束时间', 'error');
            return false;
        }
        if (etime != '' && stime == '') {
            $.messager.alert('提示', '请先输入起始时间', 'error');
            return false;
        }
        $('#gridList').datagrid('load', {
            tj: $("#GroupID").combo('getValue'),
            search: $("#Search").val(),
            etime: etime,
            stime: stime,
        });
    }

    function Searchall() {
        $('#gridList').datagrid('load', {
        });
    }

    function daochu() {
        var stime = $('#stime').datebox('getValue');
        var etime = $('#etime').datebox('getValue');
        if (stime != "" && etime == "") {
            $.messager.alert('提示', '请先输入结束时间', 'error');
            return false;
        }
        if (etime != '' && stime == '') {
            $.messager.alert('提示', '请先输入起始时间', 'error');
            return false;
        }

        location.href = "daochu.html?stime=" + stime + "&etime=" + etime;
    }

    //查看名称产品列表
    //  show_wxjl = function (sn) { 
    //     //alert(id);
    //     window.parent.window.MenuClickHrefEvent('/admin/fix/sn_details?sn='+sn, '维修记录', 'tabsChildContent_0', false);
    // };


    //查看维修记录
    var dWidth = $(window).width() * 1;
    var dHeight = $(window).height() * 1;
    function show_wxjl(id) {
        window.showBusinessForm("维修记录", '/admin/fix/details.html?id=' + id, dWidth, dHeight);
    }


    //查看保修卡
    var cWidth = $(window).width() * 0.6;
    var cHeight = $(window).height() * 1.05;
    function show_bxk(id) {
        window.showBusinessForm("保修卡", '/admin/card/see.html?id=' + id, cWidth, cHeight);

        //    $(".panel-body.panel-body-noborder.window-body").css({"height":"730px !important"});

    }




    //维修记录
    function wxjlAction(val, row, index) {
        if (row.wxjl == 0) {
            val = '<a href="#" title="维修记录" style="color:#333;">无记录</a>';
        } else {
            if (row.sn == '') {
                val = '<a href="#" title="维修记录" style="color:#333;">无记录</a>';
            } else {
                val = '<a href="#" onclick="show_wxjl(' + row.wxjl_id + ')" title="维修记录" style="color:#1024EE;">查看（' + row.wxjl + '条）</a>';
            }

        }


        return val;
    }
    //激活审核按钮
    function jhshAction(val, row, index) {
        {eq name="power.activate" value="true"}
        if (row.jhsh == 1) {
            val = '<a href="#" title="通过" style="color:#1024EE;" onclick="addTags(' + row.id + ')">通过</a> | ' +
                '<a href="#" title="拒绝" style="color:#1024EE;" onclick="addStatus(' + row.id + ', 2)">拒绝</a>';
            return val;
            return val;

        } else {
            val = '';
        }
        {/eq}

        return val;
    }


    function addTags(id) {
        if (id <= 0) {
            $.messager.alert('提示', "没有ID", 'info');
            return 0;
        } else {
            window.showBusinessForm("保修激活", '/admin/active/active.html?id=' + id);
        }


    }

    function addStatus(id, checkstatus) {
        if (id <= 0) {
            $.messager.alert('提示', "操作失败", 'info');
            return 0;
        }

        $.messager.confirm('提示', '确定进行操作吗？', function (r) {
            if (r) {
                $.ajax({
                    type: "POST",
                    url: 'add_status.html?id=' + id + '&checkstatus=' + checkstatus,
                })
                    .success(function (result) {
                        if (result.status > 0) {
                            $.messager.alert('提示', result.msg, "info");
                            window.location.reload();
                        } else {
                            $.messager.alert('提示', result.msg, "error");
                        }
                    })
                    .error(function (result) {
                        var message = "很抱歉，操作出现异常！请联系管理员。";
                        if (result) {
                            if (result.responseJSON && result.responseJSON.ExceptionMessage) {
                                message = result.responseJSON.ExceptionMessage;
                            }
                            else if (result.responseText) {
                                message = result.responseText;
                            }
                        }

                        $.messager.alert('错误', message.replace("-10", ""), 'error');
                    });
            }
        });
    }

    //查看详情
    function bxztAction(val, row, index) {
        if (row.jhsh == 2) {
            val = val = '<a href="#" onclick="show_bxk(' + row.bxjh_id + ')" title="保修卡" style="color:#1024EE;">查看详情（保修卡）</a>';
            return val;

        } else {
            val = '无';
        }


        return val;
    }



</script>
<div id="win"></div>
<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'north',border:false" class="grid-toolbar-panel" id="gridList_ToolBar">

        <a href="#" id="news" class="easyui-linkbutton grid-toolbar-button"></a>

        <span style="padding-left:50px;">按条件查询：
            <select class="easyui-combobox" name="state" id="GroupID" data-options="required:true,tipPosition:'right',"
                style="width:152px;">
                <option value="0">按商品序列号</option>
                <option value='1'>按商品名称</option>
            </select>
            <input type="text" id="Search" />
            &nbsp;&nbsp;
            起始时间：<input id="stime" type="text" class="easyui-datebox" style="width:100px;" value="">-
            结束时间：<input id="etime" type="text" class="easyui-datebox" style="width:100px;" value="">
            <a href="#" style="padding-left:10px;" onclick="Search()">查询</a>
            <a href="#" style="padding-left:10px;" onclick="Searchall()">全部</a>
            {eq name="power.export" value="true"}
            <a href="#" style="padding-left:10px;" onclick="daochu()">导出数据</a>
            {/eq}
        </span>

    </div>
    <div data-options="region:'center',border:false">
        <table id="gridList" class="easyui-datagrid" exusagetype="MultiSelection"
            data-options="striped: true,singleSelect: true,collapsible: true,rownumbers: true,fit: true,pagination:true,pageSize:15,pageList:[10,15,20]"
          >

            <thead data-options="frozen:true">
                <tr>
                    <th data-options="field:'cz',width:60,halign:'center',align:'center',formatter:formatAction">操作
                    </th>
                     <th data-options="field:'id',width:60,halign:'center',align:'left',sortable:true"><span
                            class="grid-header-sortable">商品ID</span></th>
                    <th data-options="field:'name',halign:'center',align:'left',width:200,sortable:true"><span
                            class="grid-header-sortable">商品名称</span></th>
                    <th data-options="field:'model',halign:'center',align:'left',width:120,sortable:true"><span
                            class="grid-header-sortable" >商品型号</span></th>
                    <th data-options="field:'sn',halign:'center',align:'left',width:150,sortable:true"><span
                            class="grid-header-sortable">商品序列号</span></th>
                    <th data-options="field:'attr_sn',halign:'center',align:'left',width:150,sortable:true"><span
                            class="grid-header-sortable">关联序列号</span></th>
                    <th data-options="field:'brand',halign:'center',align:'left',width:120,sortable:true"><span
                            class="grid-header-sortable">商品品牌</span></th>
                    <th data-options="field:'series',halign:'center',align:'left',width:120,sortable:true"><span
                            class="grid-header-sortable">商品类别</span></th>
                    <th data-options="field:'company',halign:'center',align:'left',width:120,sortable:true"><span
                            class="grid-header-sortable">商品公司</span></th>
                    <th data-options="field:'addtime',halign:'center',align:'left',width:100,sortable:true"><span
                            class="grid-header-sortable">入库时间</span></th>
                    <th data-options="field:'outtime',halign:'center',align:'left',width:100,sortable:true"><span
                            class="grid-header-sortable">出库时间</span></th>
                    <th data-options="field:'wxjl',halign:'center',align:'left',width:80,formatter:wxjlAction,sortable:true"><span
                            class="grid-header-sortable">维修记录</span></th>
                    <th data-options="field:'bxjh',halign:'center',align:'left',width:80,sortable:true"><span
                            class="grid-header-sortable">保修激活</span></th>
                    <th data-options="field:'jhsh',halign:'center',align:'left',width:100,formatter:jhshAction,sortable:true"><span
                            class="grid-header-sortable">激活审核按钮</span></th>
                    <th data-options="field:'bxzt',halign:'center',align:'left',width:150,formatter:bxztAction,sortable:true"><span
                            class="grid-header-sortable">保修状态</span></th>
                    <th data-options="field:'gys_name',halign:'center',align:'left',width:120,sortable:true"><span
                            class="grid-header-sortable">供应商名称</span></th>
                    <th data-options="field:'user',halign:'center',align:'left',width:150,sortable:true"><span
                            class="grid-header-sortable">客户姓名</span></th>
                    <th data-options="field:'mobile_phone',halign:'center',align:'left',width:150,sortable:true"><span
                            class="grid-header-sortable">手机</span></th>
                    <th data-options="field:'phone',halign:'center',align:'left',width:150,sortable:true"><span
                            class="grid-header-sortable">固话</span></th>
                    <th data-options="field:'danwei',halign:'center',align:'left',width:150,sortable:true"><span
                            class="grid-header-sortable">单位名称</span></th>
                </tr>
            </thead>

        </table>

    </div>
</div>
{include file="public/footer"/}